package cn.entity.img;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Fireball extends JPanel {
    private int x;
    private int y;
    private int playY;
    private int playX;
    private int width;
    private int height;
    private BufferedImage[] images;
    private BufferedImage image;
    private int index;

    public Fireball(int x,int y,int playY,int playX) throws IOException {
        this.x = x;
        this.y = y;
        this.playY = playY;
        this.playX = playX;
        index = 0;
        images = new BufferedImage[4];
        for(int i = 0; i < images.length; i++) {
            images[i]= ImageIO.read(new File("img/shall/B"+i+".png"));
        }
    }
    public void paintComponent(Graphics g){
        g.drawImage(getImage(),x,y,150,45,null);
    }
    public BufferedImage getImage(){
        return image;
    }
    public void setImage(int i){
        image = images[i];
    }
    public int getIndex(){
        return index;

    }
    public void setIndex(int index){
        this.index = index;
    }
   public int getImageLength(){
        return images.length;
   }
   public void step(){
        x-=10;
   }
   public void step1(){
       this.x -= 10;
       if (this.y > playY) {
           this.y -= 5;
       } else if (this.y < playY) {
           this.y += 5;
       }
   }
   public int getX(){
        return x;
   }
   public int getY(){
        return y;
   }
   public void setX(int x){
        this.x = x;
   }

}
